//
//  ClassCourseTime-DetailModel.m
//  HTP
//
//  Created by admin on 15/11/10.
//  Copyright © 2015年 nit. All rights reserved.
//

#import "ClassCourseTime-DetailModel.h"

@implementation ClassCourseTime_DetailModel
+ (ClassCourseTime_DetailModel *)toClassCourseTimeDetailM:(ClassCourse *)classCourse{
    ClassCourseTime_DetailModel *cctDetailM = [[ClassCourseTime_DetailModel alloc] init];
    cctDetailM.cgcDate          = classCourse.cgcDate;
    cctDetailM.crAccess         = classCourse.crAccess;
    cctDetailM.crAccessContent  = classCourse.crAcessContent;
    cctDetailM.crTchSummary     = classCourse.crTchSummary;
    cctDetailM.cgcDate          = classCourse.cgcDate;
    cctDetailM.cgcId            = classCourse.cgcId;
    cctDetailM.cgCount          = classCourse.cgCount;
    cctDetailM.cgRemainCount    = classCourse.cgRemainCount;
    cctDetailM.crId             = classCourse.crId;
    cctDetailM.cgcStartTime     = classCourse.cgcStartTime;
    cctDetailM.cgcStopTime      = classCourse.cgcStopTime;
    cctDetailM.cgcStatus        = classCourse.cgcStatus;
    cctDetailM.className        = classCourse.subClassName;
    cctDetailM.teacherName      = classCourse.teacherName;
    cctDetailM.tchPhotoPath     = classCourse.tchPhotoPath;
    cctDetailM.nStatus          = classCourse.nStatus;
    cctDetailM.cgAddress        = classCourse.cgAddress;
    return cctDetailM;
}
+ (NSArray *)toClassCourseTime_Detail:(NSArray *)classCourses{
    NSMutableArray *arrays = [NSMutableArray array];
    [classCourses enumerateObjectsUsingBlock:^(id  _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
        ClassCourse *classCourse = (ClassCourse *)obj;
        [arrays addObject:[ClassCourseTime_DetailModel toClassCourseTimeDetailM:classCourse]];
    }];
    return [NSArray arrayWithArray:arrays];
}
- (BOOL)saveByClassCourse{
    ClassCourse *classCourse = [ClassCourse findFirstByAttribute:@"cgcId" withValue:self.cgcId];
    if (classCourse == nil) {
        classCourse = [ClassCourse createEntity];
    }
    classCourse.cgcDate          = self.cgcDate;
    classCourse.crAccess         = self.crAccess;
    classCourse.crAcessContent   = self.crAccessContent;
    classCourse.crTchSummary     = self.crTchSummary;
    classCourse.cgcDate          = self.cgcDate;
    classCourse.cgCount          = self.cgCount;
    classCourse.cgRemainCount    = self.cgRemainCount;
    classCourse.crId             = self.crId;
    classCourse.cgcStartTime     = self.cgcStartTime;
    classCourse.cgcStopTime      = self.cgcStopTime;
    classCourse.cgcStatus        = self.cgcStatus;
    classCourse.subClassName     = self.className;
    classCourse.tchPhotoPath     = self.tchPhotoPath;
    classCourse.cgAddress        = self.cgAddress;
    return [XLCoreDataManager save];
}
@end
